package router

import (
	jwt "gitee.com/sansaniot/ssiot-core/httpmvc/jwtauth"
	"github.com/gin-gonic/gin"

	"ssdevice/internal/device/apis"
)

func init() {
	RouterCheckRole = append(RouterCheckRole, registerProductRouter)
}

func registerProductRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
	api := apis.Product{}
	// 产品
	r := v1.Group("/api/product").Use(authMiddleware.MiddlewareFuncWithOutValidate())
	{
		r.GET("/find", api.FindList)
		r.GET("/get", api.FindOne)
		r.POST("/add", api.AddProduct)
		r.POST("/modify", api.EditProduct)
		r.POST("/remove", api.DeleteProduct)
		r.POST("/copy", api.ProductCopy)
		r.POST("/devSync", api.ProductDevSync)
		r.GET("/export", api.ExportProduct)
		r.POST("/import", api.ImportProduct)
		r.POST("/config/save", api.UpsertEntireConfig)
	}
}
